package com.willcode.demo.mvc.model.mapper;

import com.willcode.demo.mvc.model.entity.SexEnum;
import com.willcode.demo.mvc.model.entity.TempUserInfo4Enum;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

/**
 * @author Will
 */
@Mapper
public interface ITempUserInfoMapper4Enum
{

    /**
     * 插入数据
     * @param tempUserInfo
     * @return
     */
    @Insert("insert into tempuserinfo (id,code,name,password,sex)values(#{id},#{code},#{name},#{password},#{sex})")
    int insert(TempUserInfo4Enum tempUserInfo);

    /**
     * 删除数据
     * @param id
     * @return
     */
    @Delete("delete from tempuserinfo where id = #{id}")
    int deleteById(String id);

    /**
     * 更新数据
     * @param tempUserInfo
     * @return
     */
    @Update("update tempuserinfo set code = #{code},name = #{name},password = #{possword},sex = #{sex} where id = #{id}")
    int updateByid(TempUserInfo4Enum tempUserInfo);

    /**
     * 检索数据
     * @param id
     * @return
     */
    @Select("select id,code,name,password,sex from tempuserinfo where id = #{id}")
    TempUserInfo4Enum selectByid(String id);

    /**
     * 查询数据
     * @return
     */
    @Select("select id,code,name,password,sex from tempuserinfo")
    @Results({
            @Result(property = "sex",  column = "sex", javaType = SexEnum.class, jdbcType = JdbcType.VARCHAR),
            @Result(property = "name", column = "name")
    })
    List<TempUserInfo4Enum> selectAllTempUserInfo();
}
